<?php if (isset($editMode)): ?>
    <form action="<?= base_url('hockey/update/' . esc($record['id'])) ?>" method="post">
        <?= csrf_field() ?>

        <?php if (isset($errors)): ?>
            <div class="alert alert-danger" role="alert">
                <?php foreach ($errors as $error): ?>
                    <p><?= esc($error) ?></p>
                <?php endforeach; ?>
            </div>
        <?php endif; ?>

        <div class="mb-3">
            <label for="name" class="form-label">Name</label>
            <input type="text" class="form-control" id="name" name="name" value="<?= esc($record['name']) ?>">
        </div>

        <div class="mb-3">
            <label for="city" class="form-label">City</label>
            <input type="text" class="form-control" id="city" name="city" value="<?= esc($record['city']) ?>">
        </div>

        <div class="mb-3">
            <label for="powers" class="form-label">Powers</label>
            <textarea class="form-control" id="powers" name="powers"><?= esc($record['powers']) ?></textarea>
        </div>

        <div class="mb-3">
            <label for="weapon" class="form-label">Weapon</label>
            <input type="text" class="form-control" id="weapon" name="weapon" value="<?= esc($record['weapon']) ?>">
        </div>

        <button type="submit" class="btn btn-primary">Update Hero</button>
        <a href="<?= base_url('hockey/showme/' . esc($record['id'])) ?>" class="btn btn-secondary">Cancel</a>
    </form>
<?php else: ?>
    <table class="table">
        <thead>
            <tr>
                <th>Field</th>
                <th>Value</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>ID</td>
                <td><?= esc($record['id']) ?></td>
            </tr>
            <tr>
                <td>Name</td>
                <td><?= esc($record['name']) ?></td>
            </tr>
            <tr>
                <td>City</td>
                <td><?= esc($record['city']) ?></td>
            </tr>
            <tr>
                <td>Powers</td>
                <td><?= esc($record['powers']) ?></td>
            </tr>
            <tr>
                <td>Weapon</td>
                <td><?= esc($record['weapon']) ?></td>
            </tr>
            <tr>
                <td>Image</td>
                <td><img src="/image/<?= esc($record['image']) ?>" alt="<?= esc($record['name']) ?>" style="width:200px; height:auto;"></td>
            </tr>
        </tbody>
    </table>
    <a href="#" id="editButton" class="btn btn-custom">Edit Hero</a>
<?php endif; ?>